package com.mzy.basics.jarFile;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author mzy
 * @Date 2022/5/23 13:58
 * @Version 1.0
 */

/**
 * 类加载器--获取当前项目所在路径
 */
public class OrdinaryReadWrite {
    public static void main(String[] args) {

        System.out.println(OrdinaryReadWrite.class.getResource("a.txt"));
        System.out.println(OrdinaryReadWrite.class.getResource("/a.txt"));
        System.out.println(OrdinaryReadWrite.class.getResource("/"));
        System.out.println(OrdinaryReadWrite.class.getResource("b.txt"));
        // need to add resource/b.txt to build path! it will be package in jar file
        System.out.println(OrdinaryReadWrite.class.getClassLoader().getResource("b.txt"));
        System.out.println(OrdinaryReadWrite.class.getClassLoader().getResource("/"));
        System.out.println(Thread.currentThread().getContextClassLoader().getResource("b.txt"));
    }
}
